import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';
import 'package:flutter_kit_plus/flutter_kit.dart';

import '../../common/unit_btn.dart';
import '../../tool/assets.dart';

class XoBottom extends StatefulWidget {
  const XoBottom({super.key});

  @override
  State<XoBottom> createState() => _XoBottomState();
}

class _XoBottomState extends State<XoBottom> {
  List<GroupModel> get _group_list {
    return List.generate((globalController.rxModel.value.ch_list.length / 2).toInt(), (index) {
      return GroupModel(
          ch1: globalController.rxModel.value.ch_list[2 * index],
          ch2: globalController.rxModel.value.ch_list[2 * index + 1]);
    });
  }

  @override
  void initState() {
    super.initState();
    // _restore_globalmodel = globalModel.copy;
  }

  Widget buildMyTextButton(
      {required String text,
      double width = 100,
      double radius = 4,
      Color? color,
      List<Color> colors = const [Color(0xFF9ED1E6), Color(0xFF9ED1E6)],
      required VoidCallback onTap}) {
    return myTextButton(
      width: width,
      radius: radius,
      color: color,
      colors: colors,
      onTap: onTap,
      child: Center(
        child: FittedBox(
          fit: BoxFit.scaleDown,
          child: Text(text,
              style: font30,
              textAlign: TextAlign.center,
              textHeightBehavior: const TextHeightBehavior(
                applyHeightToFirstAscent: false,
                applyHeightToLastDescent: false,
              )),
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.only(top: 10),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          const SizedBox(width: 50),
          Flexible(
            flex: 2,
            child: Container(
              height: 30,
              child: buildMyTextButton(
                  text: 'RESET',
                  width: 180,
                  color: Color_yellow,
                  colors: [Color_yellow, Colors.white.withOpacity(0.2)],
                  onTap: () => globalController.resetHi_LowPass()),
            ),
          ),
          const SizedBox(width: 20),
          Flexible(flex: 7, child: UnitBar(title: 'XO')),
          const SizedBox(width: 20),
          Flexible(
            flex: 2,
            child: Container(
              height: 30,
              child: buildMyTextButton(
                  text: 'COPY',
                  color: const Color(0xFF88B855),
                  colors: [const Color(0xFF88B855), Colors.white.withOpacity(0.2)],
                  onTap: () => globalController.pastChannel(context, 'FILTER')),
            ),
          ),
          const SizedBox(width: 20),
        ],
      ),
    );
  }
}
